package com.fg.ihr.repository;
import com.fg.ihr.domain.Department;
import com.fg.ihr.domain.Ward;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Repository
public interface DepartmentRepository extends JpaRepository<Department, Integer>,JpaSpecificationExecutor<Department> {

    @Query(nativeQuery = true,value="select u.id,u.name,u.location_id from department u left join location l on u.location_id = l.id where u.location_id = :id")
    List<Department> findLocationList(@Param("id") Integer id);

    List<Department> findAllByName(String name);

}
